﻿package org.openChart.sprite 
{
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.text.TextField;
	import org.openChart.display.DisplayColorLabel;
	import org.openChart.display.DisplayColorLabelGroup;
	
	/**
	 * ...
	 * @author Chongyuan
	 */ 
	public class ColorLabelSprite extends MouseEventSprite
	{	
		private var text:TextField = new TextField();
		public function ColorLabelSprite( displayColorLabel_:DisplayColorLabel, commandHandler:CommandHandler ) 
		{
			super(displayColorLabel_, commandHandler);
		}
		
		
		
		public override function paint():void
		{	
			var displayColorLabel_:DisplayColorLabel = displayObject as DisplayColorLabel;
			
			text.text = displayColorLabel_.label.text;
			text.width = text.textWidth + 5;
			text.height = text.textHeight + 5;
			
			this.addChild(text);
			text.x = displayColorLabel_.position.x + displayColorLabel_.size;
			text.y = displayColorLabel_.position.y;
			
			if (displayColorLabel_.shape == DisplayColorLabel.DOT)
			{
				fillEllipse(displayObject.position.x + displayColorLabel_.size / 2, displayObject.position.y + displayColorLabel_.size / 2, displayColorLabel_.size / 2, displayColorLabel_.size / 2, displayObject.color);
			}
			else if (displayColorLabel_.shape == DisplayColorLabel.LINE)
			{
				drawLine(displayObject.position.x, displayObject.position.y + 2*displayColorLabel_.size/3, displayObject.position.x + displayColorLabel_.size, displayObject.position.y + 2*displayColorLabel_.size / 3, 3, displayObject.color);
			}
			else if (displayColorLabel_.shape == DisplayColorLabel.SQUARE)
			{
				
				fillRectangle(displayObject.position.x, displayObject.position.y, displayColorLabel_.size, displayColorLabel_.size, displayObject.color);
			}
		}
		
	}
	
}